<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 								
	<head> 							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	$(document).ready(function(){
	
			
				//高级搜索需要的js
				buttonStatus=1;
				$("#flip").click(function(){
					if(buttonStatus==1){
						$("#panel").slideToggle("slow");
						$("#flip").toggleClass("btnStatus2");
						buttonStatus=1;
					}
					else{
						$("#panel").slideUp("slow");
						$("#flip").toggleClass("btnStatus2");
					}
			 });
				 //高级搜索结束
	
					$("#gridTable").jqGrid({
						url:'<%=request.getContextPath()%>/shebeiweibaoqueryAction!queryShebeiweibaoList.action',
						datatype: "json",
						height: 450,
						width: 710, 
						autowidth: true, 
						colNames:['ID','设备id','设备名称','维保项目','维保基准','测量变量方法','操作要点','设备编号','规格型号','部门id','部门名称','序号','保养级别','工具','劳保','保养周期','上次保养时间','保养时间','提醒天数'],
                    colModel:[
                        {name:'ID',index:'ID', width:60, key:true,hidden:true,hidedlg:true}, 
                        		{name:'SHEBEIID',index:'SHEBEIID', width:100,hidden:true},
                        		{name:'SHEBEINAME',index:'SHEBEINAME', width:100},
                        		{name:'WEIBAOXIANGMU',index:'WEIBAOXIANGMU', width:100,hidden:true},	
								{name:'WEIBAOJIZHUN',index:'WEIBAOJIZHUN', width:100},								
								{name:'CELIANGBIANLIANG',index:'CELIANGBIANLIANG', width:100},
								{name:'CAOZUOYAODIAN',index:'CAOZUOYAODIAN', width:110},
								{name:'SHEBEINO',index:'SHEBEINO', width:110},
								{name:'GUIGEXINGHAO',index:'GUIGEXINGHAO', width:110},
								{name:'BUMENID',index:'BUMENID', width:50,hidden:true},
								{name:'BUMENNAME',index:'BUMENNAME', width:50},
								{name:'XUHAO',index:'XUHAO', width:110,hidden:true},
								{name:'BAOYANGJIBIE',index:'BAOYANGJIBIE', width:110},
								{name:'GONGJU',index:'GONGJU', width:110},
								{name:'LAOBAO',index:'LAOBAO', width:50},
								{name:'BAOYANGZHOUQI',index:'BAOYANGZHOUQI', width:80,hidden:true},
								{name:'SHANGCIWEIBAOTIME',index:'SHANGCIWEIBAOTIME',width:110,hidden:true},
								{name:'WEIBAOTIME',index:'WEIBAOTIME',width:110},
								{name:'TIXINGTIANSHU',index:'TIXINGTIANSHU', width:110,hidden:true}
                    ],      
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					loadComplete: function() {
						var ids = jQuery("#gridTable").getDataIDs();
				        if(ids.length<20){
				        	 jQuery("#gridTable").jqGrid('setGridHeight',390); 
				        	 parent.document.getElementById("mainframe").height=670; 
				        }else{
				        	 jQuery("#gridTable").jqGrid('setGridHeight',ids.length*24); 
				        	 parent.document.getElementById("mainframe").height=ids.length*24+410; 
				        }
				        var n = jQuery("#gridTable").getGridParam('records'); 
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "维保查询台帐"
			});
			    $("#consoleDlg").dialog({
			        autoOpen: false,      
			        modal: true,    // 设置对话框为模态（modal）对话框  
			        resizable: true,      
			        width: 700,  
			        buttons: {  // 为对话框添加按钮  
			            "关闭": function() {$("#consoleDlg").dialog("close")}
			        }  
			    }); 
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
								doResize(); 
							//	afterCompleteFunction();										
	}); 
	
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-245);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
			} 
		
	
		
		//查询
		function gridSearch(){
			var bumenname = $.trim(jQuery("#bumenname").val());
            var shebeiname = $.trim(jQuery("#shebeiname").val()); 
            var shebeino = $.trim(jQuery("#shebeino").val());
            var guigexinghao = $.trim(jQuery("#guigexinghao").val());
            var weibaoxiangmu = $.trim(jQuery("#weibaoxiangmu").val()); 
            var weibaojizhun = $.trim(jQuery("#weibaojizhun").val());
            var celiangbianliang = $.trim(jQuery("#celiangbianliang").val());
            var baoyangjibie = $.trim(jQuery("#baoyangjibie").val()); 
            var startweibaotime = $.trim(jQuery("#startweibaotime").val());
            var endweibaotime = $.trim(jQuery("#endweibaotime").val());
            var params = {  
                        "bumenname" : encodeURIComponent(bumenname),                           
                        "shebeiname" : encodeURIComponent(shebeiname),
                        "shebeino" : encodeURIComponent(shebeino),                           
                        "guigexinghao" : encodeURIComponent(guigexinghao),
                        "weibaoxiangmu" : encodeURIComponent(weibaoxiangmu),                           
                        "weibaojizhun" : encodeURIComponent(weibaojizhun),
                        "celiangbianliang" : encodeURIComponent(celiangbianliang),                           
                        "baoyangjibie" : encodeURIComponent(baoyangjibie),
                         "startweibaotime" : startweibaotime,
                        "endweibaotime" : endweibaotime
                         };
            var postData = $("#gridTable").jqGrid("getGridParam", "postData");
            $.extend(postData, params);
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath() %>/shebeiweibaoqueryAction!queryShebeiweibaoList.action'
			}).trigger("reloadGrid", [{page:1}]);
        } 
       
		//刷新
		function refreshIt(){
			//resetSearch();
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath() %>/shebeiweibaoqueryAction!queryShebeiweibaoList.action'
			}).trigger("reloadGrid", [{page:1}]);
		    
		}
		function reload(){
			refreshIt();
		}
		//清空
		function reset(){
			jQuery("#bumenname").val("");
			jQuery("#shebeiname").val("");
			jQuery("#shebeino").val("");
			jQuery("#guigexinghao").val("");	
			jQuery("#weibaoxiangmu").val("");
			jQuery("#weibaojizhun").val("");
			jQuery("#celiangbianliang").val("");
			jQuery("#baoyangjibie").val("");
			jQuery("#startweibaotime").val("");
			jQuery("#endweibaotime").val("");
		}
		
		
	   
		//导出
		function expExcel(){
			var colNames = jQuery("#gridTable").jqGrid('getGridParam','colNames');
			var titleNames ="";
			var fieldsNames ="";
			for(var i=2;i<colNames.length;i++){
			titleNames+=colNames[i]+",";
			} 
			titleNames = encodeURIComponent(titleNames);
			var colModel = jQuery("#gridTable").jqGrid('getGridParam','colModel');
			for(var i=2;i<colModel.length;i++){
			fieldsNames+=colModel[i]["name"]+",";
			} 
			fieldsNames = encodeURIComponent(fieldsNames);
			$('#form1').attr("action","<%=request.getContextPath() %>/shebeiweibaoqueryAction!exportExcel.action?titleNames="+titleNames+"&fieldsNames="+fieldsNames);
			$('#form1').submit();
		}
		
	</script>	
	</head>
	<body>
	<form action="" method="post" id="form1">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
		   		<td>
			 		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			   		<tr>
			        	<td width="6%" height="35" align="right">部门名称：</td>
			        	<td width="11%"><input type="text" name="bumenname" id="bumenname" class="search_InputText" style="width:99%;"/></td>
			        	<td width="9%" height="35" align="right">设备名称：</td>
			        	<td width="11%"><input type="text" name="shebeiname" id="shebeiname"  class="search_InputText" style="width:99%;" /> </td>
			        	<td width="6%" height="35" align="right">设备编号：</td>
			        	<td width="11%"><input type="text" name="shebeino" id="shebeino" class="search_InputText" style="width:99%;"/></td>
			        	<td width="9%" height="35" align="right">规格型号：</td>
			        	<td width="11%"><input type="text" name="guigexinghao" id="guigexinghao"  class="search_InputText" style="width:99%;" /> </td>
			            <td width="15%" align="right">&nbsp;<input type="button" name="button" id="button" value="查询" onclick="gridSearch()" class="search_Btn" />
			      			&nbsp;<input type="reset" name="button2" id="button2" value="清空" onclick="reset()" class="search_Btn" />
			      		</td>
			        </tr>
			      </table>
			      <div id="panel" style="display:none;">
			      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			      	 <tr>
			        	<td width="6%" height="35" align="right">维保项目：</td>
			        	<td width="11%"><input type="text" name="weibaoxiangmu" id="weibaoxiangmu" class="search_InputText" style="width:99%;"/></td>
			        	<td width="9%" height="35" align="right">维保基准：</td>
			        	<td width="11%"><input type="text" name="weibaojizhun" id="weibaojizhun"  class="search_InputText" style="width:99%;" /> </td>
			        	<td width="11%" height="35" align="right">测量变量方法：</td>
			        	<td width="11%"><input type="text" name="celiangbianliang" id="celiangbianliang" class="search_InputText" style="width:99%;"/></td>
			        	<td width="9%" height="35" align="right">保养级别：</td>
			        	<td width="11%"><input type="text" name="baoyangjibie" id="baoyangjibie"  class="search_InputText" style="width:99%;" /> </td>
			            <td></td>
			        </tr>
			        <tr>
			        	<td width="8%" height="35" align="right">开始日期：</td>
			        	<td width="11%"><input type="text" name="startweibaotime" id="startweibaotime" onClick="WdatePicker()" class="search_InputText" style="width:99%;" /> </td>
			        	<td width="8%" height="35" align="right">结束时间：</td>
			        	<td width="11%"><input type="text" name="endweibaotime" id="endweibaotime" onClick="WdatePicker()" class="search_InputText" style="width:99%;" /> </td>
			      	</tr>
			    </table>
			    </div>		    
		  		</td>
		 	  </tr>
		      <tr>
                <td align="right" height="9" class="sclinebotBg"></td>
	          </tr>
		      <tr>
			    <td width="92%" align="right"><div class="btnStatus" id="flip"></div></td>
			    <td width="8%">&nbsp;</td>
			  </tr>
			</table>
			<table style="width: 100%;" class="tableCont">
				<tr>
					<td>
						<input style="width: 100px" type="button" name="button" id="button" value="生成维保记录" onclick="expExcel()" class="search_Btn" />
					</td>
				</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
		   </table>
	</form>
	</body>
</html>
